package cn.iocoder.yudao.module.handguard.controller.app.userbasetable13;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;

import cn.iocoder.yudao.module.handguard.controller.app.userbasetable13.vo.*;
import cn.iocoder.yudao.module.handguard.dal.dataobject.userbasetable13.UserBaseTable13DO;
import cn.iocoder.yudao.module.handguard.convert.userbasetable13.UserBaseTable13Convert;
import cn.iocoder.yudao.module.handguard.service.userbasetable13.UserBaseTable13Service;

@Tag(name = "小程序 - 企业发票贷")
@RestController
@RequestMapping("/hutai/user-base-table13")
@Validated
public class UserBaseTable13Controller {

    @Resource
    private UserBaseTable13Service userBaseTable13Service;

    @PostMapping("/create")
    @Operation(summary = "创建企业发票贷")
    public CommonResult<Long> createUserBaseTable13(@Valid @RequestBody UserBaseTable13CreateReqVO createReqVO) {
        return success(userBaseTable13Service.createUserBaseTable13(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新企业发票贷")
    public CommonResult<Boolean> updateUserBaseTable13(@Valid @RequestBody UserBaseTable13UpdateReqVO updateReqVO) {
        userBaseTable13Service.updateUserBaseTable13(updateReqVO);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得企业发票贷")
    public CommonResult<UserBaseTable13RespVO> getUserBaseTable13(Long ui) {
//        Long userId =ui;
//        //当前用户id
//        if (userId <= 0l) {
//            userId = getLoginUser().getId();
//        }
        UserBaseTable13DO userBaseTable13 = userBaseTable13Service.getUserBaseTable13(ui);
        return success(UserBaseTable13Convert.INSTANCE.convert(userBaseTable13));
    }



}
